import 'package:go_router/go_router.dart';
import 'package:schedule_self_client/ui/pages/app_layout.dart';
import 'package:schedule_self_client/ui/pages/download_loading_page.dart';
import 'package:schedule_self_client/ui/pages/login_page.dart';
import 'package:schedule_self_client/ui/pages/splash_page.dart';
import 'package:schedule_self_client/ui/pages/task_category_mgmt.dart';
import 'package:schedule_self_client/ui/pages/task_detail_page.dart';

final router = GoRouter(
  initialLocation: '/',
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => const SplashPage(),
    ),
    GoRoute(
      path: '/main',
      builder: (context, state) => const AppLayout(),
    ),
    GoRoute(
      path: '/login',
      builder: (context, state) => const LoginPage(),
    ),
    GoRoute(
      path: '/task_detail',
      builder: (context, state) {
        final int taskId = state.extra! as int;
        return TaskDetailPage(taskId: taskId);
      },
    ),
    GoRoute(
      path: '/task_category_mgmt',
      builder: (context, state) => const TaskCategoryMgmt(),
    ),
    GoRoute(
      path: '/download_loading_page',
      builder: (context, state) =>
          const DownloadLoadingPage(title: '新app正在下载中'),
    )
  ],
);
